﻿namespace ACCOUNTING.LVY.Business
{
    using ACCOUNTING;
    using Microsoft.VisualBasic.CompilerServices;
    using System;
    using System.Data;
    using System.Windows.Forms;

    public class clsTamUngNhaCungCapChiTietChiPhi
    {
        private string mDiaChiThue = "";
        private string mDienGiaiAnh = "";
        private string mDienGiaiMatHang = "";
        private string mDienGiaiViet = "";
        private int mFlag = 0;
        private string mKhoa = "";
        private string mKhoaDoiTuong = "";
        private string mKhoaDoiTuongCo = "";
        private string mKhoaDoiTuongThue = "";
        private string mKhoaDonVi = "";
        private string mKhoaLoaiTien = "";
        private string mKhoaPhuongThucThue = "";
        private string mKhoaTaiKhoanCo = "";
        private string mKhoaTaiKhoanNo = "";
        private string mKhoaTamUng = "";
        private string mMaSoThue = "";
        private string mNgayChungTu = "";
        private string mNgayHoaDon = "";
        private string mSoChungTu = "";
        private string mSoHoaDon = "";
        private string mSoSeri = "";
        private double mSoTien = 0.0;
        private double mSoTienGhiSo = 0.0;
        private string mTenDoiTuongThue = "";
        private int mThueSuat = 0;
        private double mTienThue = 0.0;
        private double mTienThueGhiSo = 0.0;
        private double mTienThueKhauTru = 0.0;
        private double mTienThueKhauTruGhiSo = 0.0;
        private string mTyGia = "";

        public bool DelData(string pKhoa)
        {
            IDataParameter parameter = null;
            bool flag=false;
            string commandText = "";
            try
            {
                commandText = "DELETE FROM GL_TamUngNhaCungCapChiTietChiPhi WHERE KhoaTamUng = '" + pKhoa.Trim() + "'";
                bool flag2 = DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[] { parameter }) > 0;
                flag = flag2;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public DataTable GetListTamUngNhaCungCapChiPhi(string strKhoa)
        {
            DataTable table;
            try
            {
                string commandText = "select TUCP.*, DMTK.SOTAIKHOAN, DMTK.TENVIET TENTAIKHOAN, DMLT.MA, DMLT.TENVIET TENLOAITIEN, DMDT.MA MADOITUONG, DMDT.TENVIET TENDOITUONG from GL_TamUngNhaCungCapChiTietChiPhi TUCP left join DM_TAIKHOAN DMTK on TUCP.KHOATAIKHOANNO = DMTK.KHOA left join DM_LOAITIEN DMLT on TUCP.KHOALOAITIEN = DMLT.MA left join DM_DOITUONG DMDT on TUCP.KHOADOITUONG = DMDT.KHOA where TUCP.KHOATAMUNG = '" + strKhoa + "'";
                table = DBHelper.ExecuteDataset(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]).Tables[0];
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message);
                table = null;
                ProjectData.ClearProjectError();
                return table;
                ProjectData.ClearProjectError();
            }
            return table;
        }

        public bool Load(string pKhoa)
        {
            bool flag=false;
            try
            {
                string commandText = "SELECT * FROM GL_TamUngNhaCungCapChiTietChiPhi WHERE Khoa = '" + pKhoa + "'";
                IDataReader dataReader = DBHelper.ExecuteReader(modGeneral.ConnectionString, CommandType.Text, commandText, new IDataParameter[0]);
                if (dataReader.Read())
                {
                    this.mKhoa = Conversions.ToString(modGeneral.GetValue(dataReader, 0, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTamUng = Conversions.ToString(modGeneral.GetValue(dataReader, 1, modGeneral.typeOfColumn.GetString));
                    this.mSoChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 2, modGeneral.typeOfColumn.GetString));
                    this.mNgayChungTu = Conversions.ToString(modGeneral.GetValue(dataReader, 3, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTaiKhoanNo = Conversions.ToString(modGeneral.GetValue(dataReader, 4, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuong = Conversions.ToString(modGeneral.GetValue(dataReader, 5, modGeneral.typeOfColumn.GetString));
                    this.mKhoaLoaiTien = Conversions.ToString(modGeneral.GetValue(dataReader, 6, modGeneral.typeOfColumn.GetString));
                    this.mTyGia = Conversions.ToString(modGeneral.GetValue(dataReader, 7, modGeneral.typeOfColumn.GetString));
                    this.mSoTien = Conversions.ToDouble(modGeneral.GetValue(dataReader, 8, modGeneral.typeOfColumn.GetDecimal));
                    this.mSoTienGhiSo = Conversions.ToDouble(modGeneral.GetValue(dataReader, 9, modGeneral.typeOfColumn.GetDecimal));
                    this.mThueSuat = Conversions.ToInteger(modGeneral.GetValue(dataReader, 10, modGeneral.typeOfColumn.GetInt32));
                    this.mTienThue = Conversions.ToDouble(modGeneral.GetValue(dataReader, 11, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThueGhiSo = Conversions.ToDouble(modGeneral.GetValue(dataReader, 12, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThueKhauTru = Conversions.ToDouble(modGeneral.GetValue(dataReader, 13, modGeneral.typeOfColumn.GetDecimal));
                    this.mTienThueKhauTruGhiSo = Conversions.ToDouble(modGeneral.GetValue(dataReader, 14, modGeneral.typeOfColumn.GetDecimal));
                    this.mDienGiaiViet = Conversions.ToString(modGeneral.GetValue(dataReader, 15, modGeneral.typeOfColumn.GetString));
                    this.mDienGiaiAnh = Conversions.ToString(modGeneral.GetValue(dataReader, 0x10, modGeneral.typeOfColumn.GetString));
                    this.mKhoaTaiKhoanCo = Conversions.ToString(modGeneral.GetValue(dataReader, 0x11, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuongCo = Conversions.ToString(modGeneral.GetValue(dataReader, 0x12, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDoiTuongThue = Conversions.ToString(modGeneral.GetValue(dataReader, 0x13, modGeneral.typeOfColumn.GetString));
                    this.mTenDoiTuongThue = Conversions.ToString(modGeneral.GetValue(dataReader, 20, modGeneral.typeOfColumn.GetString));
                    this.mMaSoThue = Conversions.ToString(modGeneral.GetValue(dataReader, 0x15, modGeneral.typeOfColumn.GetString));
                    this.mDiaChiThue = Conversions.ToString(modGeneral.GetValue(dataReader, 0x16, modGeneral.typeOfColumn.GetString));
                    this.mSoHoaDon = Conversions.ToString(modGeneral.GetValue(dataReader, 0x17, modGeneral.typeOfColumn.GetString));
                    this.mNgayHoaDon = Conversions.ToString(modGeneral.GetValue(dataReader, 0x18, modGeneral.typeOfColumn.GetString));
                    this.mSoSeri = Conversions.ToString(modGeneral.GetValue(dataReader, 0x19, modGeneral.typeOfColumn.GetString));
                    this.mKhoaPhuongThucThue = Conversions.ToString(modGeneral.GetValue(dataReader, 0x1a, modGeneral.typeOfColumn.GetString));
                    this.mKhoaDonVi = Conversions.ToString(modGeneral.GetValue(dataReader, 0x1b, modGeneral.typeOfColumn.GetString));
                    this.mDienGiaiMatHang = Conversions.ToString(modGeneral.GetValue(dataReader, 0x1c, modGeneral.typeOfColumn.GetString));
                    this.mFlag = Conversions.ToInteger(modGeneral.GetValue(dataReader, 0x1d, modGeneral.typeOfColumn.GetInt32));
                }
                dataReader.Close();
                flag = true;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public bool Save()
        {
            bool flag=false;
            IDataParameter[] commandParameters = new IDataParameter[30];
            try
            {
                commandParameters[0] = DBHelper.createParameter("@Khoa", DbType.Int64, ParameterDirection.Input, this.mKhoa);
                commandParameters[1] = DBHelper.createParameter("@KhoaTamUng", DbType.Int64, ParameterDirection.Input, this.mKhoaTamUng);
                commandParameters[2] = DBHelper.createParameter("@SoChungTu", DbType.Int64, ParameterDirection.Input, this.mSoChungTu);
                commandParameters[3] = DBHelper.createParameter("@NgayChungTu", DbType.Int64, ParameterDirection.Input, this.mNgayChungTu);
                commandParameters[4] = DBHelper.createParameter("@KhoaTaiKhoanNo", DbType.Int64, ParameterDirection.Input, this.mKhoaTaiKhoanNo);
                commandParameters[5] = DBHelper.createParameter("@KhoaDoiTuong", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuong);
                commandParameters[6] = DBHelper.createParameter("@KhoaLoaiTien", DbType.Int64, ParameterDirection.Input, this.mKhoaLoaiTien);
                commandParameters[7] = DBHelper.createParameter("@TyGia", DbType.Int64, ParameterDirection.Input, this.mTyGia);
                commandParameters[8] = DBHelper.createParameter("@SoTien", DbType.Date, ParameterDirection.Input, this.mSoTien);
                commandParameters[9] = DBHelper.createParameter("@SoTienGhiSo", DbType.Date, ParameterDirection.Input, this.mSoTienGhiSo);
                commandParameters[10] = DBHelper.createParameter("@ThueSuat", DbType.Double, ParameterDirection.Input, this.mThueSuat);
                commandParameters[11] = DBHelper.createParameter("@TienThue", DbType.Date, ParameterDirection.Input, this.mTienThue);
                commandParameters[12] = DBHelper.createParameter("@TienThueGhiSo", DbType.Date, ParameterDirection.Input, this.mTienThueGhiSo);
                commandParameters[13] = DBHelper.createParameter("@TienThueKhauTru", DbType.Date, ParameterDirection.Input, this.mTienThueKhauTru);
                commandParameters[14] = DBHelper.createParameter("@TienThueKhauTruGhiSo", DbType.Date, ParameterDirection.Input, this.mTienThueKhauTruGhiSo);
                commandParameters[15] = DBHelper.createParameter("@DienGiaiViet", DbType.Int64, ParameterDirection.Input, this.mDienGiaiViet);
                commandParameters[0x10] = DBHelper.createParameter("@DienGiaiAnh", DbType.Int64, ParameterDirection.Input, this.mDienGiaiAnh);
                commandParameters[0x11] = DBHelper.createParameter("@KhoaTaiKhoanCo", DbType.Int64, ParameterDirection.Input, this.mKhoaTaiKhoanCo);
                commandParameters[0x12] = DBHelper.createParameter("@KhoaDoiTuongCo", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuongCo);
                commandParameters[0x13] = DBHelper.createParameter("@KhoaDoiTuongThue", DbType.Int64, ParameterDirection.Input, this.mKhoaDoiTuongThue);
                commandParameters[20] = DBHelper.createParameter("@TenDoiTuongThue", DbType.Int64, ParameterDirection.Input, this.mTenDoiTuongThue);
                commandParameters[0x15] = DBHelper.createParameter("@MaSoThue", DbType.Int64, ParameterDirection.Input, this.mMaSoThue);
                commandParameters[0x16] = DBHelper.createParameter("@DiaChiThue", DbType.Int64, ParameterDirection.Input, this.mDiaChiThue);
                commandParameters[0x17] = DBHelper.createParameter("@SoHoaDon", DbType.Int64, ParameterDirection.Input, this.mSoHoaDon);
                commandParameters[0x18] = DBHelper.createParameter("@NgayHoaDon", DbType.Int64, ParameterDirection.Input, this.mNgayHoaDon);
                commandParameters[0x19] = DBHelper.createParameter("@SoSeri", DbType.Int64, ParameterDirection.Input, this.mSoSeri);
                commandParameters[0x1a] = DBHelper.createParameter("@KhoaPhuongThucThue", DbType.Int64, ParameterDirection.Input, this.mKhoaPhuongThucThue);
                commandParameters[0x1b] = DBHelper.createParameter("@KhoaDonVi", DbType.Int64, ParameterDirection.Input, this.mKhoaDonVi);
                commandParameters[0x1c] = DBHelper.createParameter("@DienGiaiMatHang", DbType.Int64, ParameterDirection.Input, this.mDienGiaiMatHang);
                commandParameters[0x1d] = DBHelper.createParameter("@Flag", DbType.Int64, ParameterDirection.Input, this.mFlag);
                if (DBHelper.ExecuteNonQuery(modGeneral.ConnectionString, CommandType.StoredProcedure, "GL_sp_TamUngNhaCungCapChiTietChiPhi", commandParameters) > 0)
                {
                    return true;
                }
                flag = false;
            }
            catch (Exception exception1)
            {
                ProjectData.SetProjectError(exception1);
                Exception exception = exception1;
                MessageBox.Show(exception.Message.ToString());
                flag = false;
                ProjectData.ClearProjectError();
                return flag;
                ProjectData.ClearProjectError();
            }
            return flag;
        }

        public string DiaChiThue
        {
            get
            {
                return this.mDiaChiThue;
            }
            set
            {
                this.mDiaChiThue = value;
            }
        }

        public string DienGiaiAnh
        {
            get
            {
                return this.mDienGiaiAnh;
            }
            set
            {
                this.mDienGiaiAnh = value;
            }
        }

        public string DienGiaiMatHang
        {
            get
            {
                return this.mDienGiaiMatHang;
            }
            set
            {
                this.mDienGiaiMatHang = value;
            }
        }

        public string DienGiaiViet
        {
            get
            {
                return this.mDienGiaiViet;
            }
            set
            {
                this.mDienGiaiViet = value;
            }
        }

        public int Flag
        {
            get
            {
                return this.mFlag;
            }
            set
            {
                this.mFlag = value;
            }
        }

        public string Khoa
        {
            get
            {
                return this.mKhoa;
            }
            set
            {
                this.mKhoa = value;
            }
        }

        public string KhoaDoiTuong
        {
            get
            {
                return this.mKhoaDoiTuong;
            }
            set
            {
                this.mKhoaDoiTuong = value;
            }
        }

        public string KhoaDoiTuongCo
        {
            get
            {
                return this.mKhoaDoiTuongCo;
            }
            set
            {
                this.mKhoaDoiTuongCo = value;
            }
        }

        public string KhoaDoiTuongThue
        {
            get
            {
                return this.mKhoaDoiTuongThue;
            }
            set
            {
                this.mKhoaDoiTuongThue = value;
            }
        }

        public string KhoaDonVi
        {
            get
            {
                return this.mKhoaDonVi;
            }
            set
            {
                this.mKhoaDonVi = value;
            }
        }

        public string KhoaLoaiTien
        {
            get
            {
                return this.mKhoaLoaiTien;
            }
            set
            {
                this.mKhoaLoaiTien = value;
            }
        }

        public string KhoaPhuongThucThue
        {
            get
            {
                return this.mKhoaPhuongThucThue;
            }
            set
            {
                this.mKhoaPhuongThucThue = value;
            }
        }

        public string KhoaTaiKhoanCo
        {
            get
            {
                return this.mKhoaTaiKhoanCo;
            }
            set
            {
                this.mKhoaTaiKhoanCo = value;
            }
        }

        public string KhoaTaiKhoanNo
        {
            get
            {
                return this.mKhoaTaiKhoanNo;
            }
            set
            {
                this.mKhoaTaiKhoanNo = value;
            }
        }

        public string KhoaTamUng
        {
            get
            {
                return this.mKhoaTamUng;
            }
            set
            {
                this.mKhoaTamUng = value;
            }
        }

        public string MaSoThue
        {
            get
            {
                return this.mMaSoThue;
            }
            set
            {
                this.mMaSoThue = value;
            }
        }

        public string NgayChungTu
        {
            get
            {
                return this.mNgayChungTu;
            }
            set
            {
                this.mNgayChungTu = value;
            }
        }

        public string NgayHoaDon
        {
            get
            {
                return this.mNgayHoaDon;
            }
            set
            {
                this.mNgayHoaDon = value;
            }
        }

        public string SoChungTu
        {
            get
            {
                return this.mSoChungTu;
            }
            set
            {
                this.mSoChungTu = value;
            }
        }

        public string SoHoaDon
        {
            get
            {
                return this.mSoHoaDon;
            }
            set
            {
                this.mSoHoaDon = value;
            }
        }

        public string SoSeri
        {
            get
            {
                return this.mSoSeri;
            }
            set
            {
                this.mSoSeri = value;
            }
        }

        public double SoTien
        {
            get
            {
                return this.mSoTien;
            }
            set
            {
                this.mSoTien = value;
            }
        }

        public double SoTienGhiSo
        {
            get
            {
                return this.mSoTienGhiSo;
            }
            set
            {
                this.mSoTienGhiSo = value;
            }
        }

        public string TenDoiTuongThue
        {
            get
            {
                return this.mTenDoiTuongThue;
            }
            set
            {
                this.mTenDoiTuongThue = value;
            }
        }

        public int ThueSuat
        {
            get
            {
                return this.mThueSuat;
            }
            set
            {
                this.mThueSuat = value;
            }
        }

        public double TienThue
        {
            get
            {
                return this.mTienThue;
            }
            set
            {
                this.mTienThue = value;
            }
        }

        public double TienThueGhiSo
        {
            get
            {
                return this.mTienThueGhiSo;
            }
            set
            {
                this.mTienThueGhiSo = value;
            }
        }

        public double TienThueKhauTru
        {
            get
            {
                return this.mTienThueKhauTru;
            }
            set
            {
                this.mTienThueKhauTru = value;
            }
        }

        public double TienThueKhauTruGhiSo
        {
            get
            {
                return this.mTienThueKhauTruGhiSo;
            }
            set
            {
                this.mTienThueKhauTruGhiSo = value;
            }
        }

        public string TyGia
        {
            get
            {
                return this.mTyGia;
            }
            set
            {
                this.mTyGia = value;
            }
        }
    }
}

